package framework.ai;

public abstract class AbstractAIModule{

	protected int[][] board;
	
	private String gameType;
	private int width;
	private int height;
	
	protected final int EMPTY = 0;
	protected final int P1 = 1;
	protected final int P2 = 2;
	
	protected int currentPlayer = P1;
	
	protected final int UNKNOWN = 0;
	protected final int LOSE = 1;
	protected final int WIN = 2;
	protected final int DRAW = 3;
	
	public AbstractAIModule(int width, int height, String gameType) {
		this.width = width;
		this.height = height;
		this.gameType = gameType;
		board = new int[width][height];
	}
	
	public AbstractAIModule(String gameType){
		this.gameType = gameType;
	}
	
	public void setCurrentPlayer(int player) {
		this.currentPlayer = player;
	};
	
	public void togglePlayer() {
		this.currentPlayer = this.getOpponent();
	};
	
	public void setBoard(int width, int height){
		this.width = width;
		this.height = height;
		board = new int[width][height];
	}
	
	public void initBoard() {};
	
	public int getWidth(){
		return this.width;
	}
	
	public int getHeight(){
		return this.height;
	}
	
	public String getGameType(){
		return this.gameType;
	}
	
	public int[][] getBoard() {
		return this.board;
	};
	
	public int getOpponent(){
		return getCurrentPlayer() == 1 ? 2 : 1;
	}
	
	/**
	 * Do a move
	 * @param player
	 * @param move
	 */
	abstract public void doMove(int player, int move);
	
	/**
	 * Get the current player
	 * @return
	 */
	public int getCurrentPlayer(){
		return this.currentPlayer;
	}
	
	/**
	 * Get the best move
	 * @param player
	 * @return
	 */
	public abstract Integer getBestMove(int player);
	
	/**
	 * Check if the given move is valid
	 * @param move
	 * @return
	 */
	public abstract boolean isValidMove(int player, int move);
	
	/**
	 * Get the state of the board
	 * @return
	 */
	protected abstract int getState(int player);
	
	
}
